﻿using System.Xml;
using System;

namespace GeoRef.HttpUtils
{
    /// <summary>
    /// This class provides some basic http facilities.
    /// </summary>
    public class HttpRequester
    {
        /// <summary>
        /// Tries to retrieve an xml document from a given uri.
        /// </summary>
        /// <param name="uri">The uri parameter from which we want the xml document to be retrieved.</param>
        /// <exception cref="System.ArgumentNullException">If the uri parameter is null.</exception>
        /// <exception cref="System.Security.SecurityException">If the system does not have sufficient permissions 
        /// to access the location of the XML data.</exception>
        /// <exception cref="System.IO.FileNotFoundException">If the file identified by the URI does not exist.</exception>
        /// <exception cref="System.UriFormatException">If the URI format is not correct.</exception>
        /// <returns>The xml document as a <see cref="System.Xml.XmlDocument"/>.</returns>
        public static XmlDocument getXmlFromUri(string uri)
        {
            XmlReader reader = XmlReader.Create(uri);
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(reader);
            return xmlDoc;
        }
    }
}
